<?php
namespace Home\Model;
use Think\Model;
class  cateModel extends Model{


	protected $_validate = array(
		array('name','require','栏目名称不得为空！',1),  // 都有时间都验证
		array('name','','栏目名称不得重复！',1,unique,1), 
		);

	public function catetree()
	{

		$data=$this->order('sort asc')->select(); //搜索所有
		return $this->$data;
	}


	
    //子分类，childid
	public function childid($cateid)
	{
		$data=$this->select();
		return $this->getchildid($data,$cateid);
		var_dump($data);
	}


	//获取子id
	public function getchildid($data,$parentid)
	{
		static $ret=array();
		foreach ($data as $k=>$v) {
			if($v['pid']==$parentid)
			{
				$ret[]=$v['id'];
				$this->getchildid($data,$v['id']);
			}
		}

		return $ret;
	}



}